import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:example/picture_view.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String url1 =
      "https://res-kfsp-test.kefang.net/system/banner/568058d095094278960d2c37e58bfb67";

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("图片预览"),
      ),
      body: Column(
        children: <Widget>[
          GestureDetector(
            onTap: () {
              List<PicsItemModel> pics = [
                PicsItemModel(uri: url1),
                PicsItemModel(uri: url1),
                PicsItemModel(uri: url1),
              ];

              pictureView(
                context: context,
                pics: pics,
                index: 0,
              );
            },
            child: Image.network(
              "https://res-kfsp.kefang.net/user/547347727906766848/share_book/7ef7a65e75d54661a126ad4cc8171dbc.jpg",
              width: rs(400),
            ),
          ),
        ],
      ),
    );
  }

  /// 将设计稿尺寸 => 屏幕尺寸
  static double rs(double value) {
    final double w = 750; // 设计稿宽度
    return value / w * window.physicalSize.width / window.devicePixelRatio;
  }
}
